@extends('home.lrf_layouts')
@section('body')
<body class="red">
<div id="login-page" class="row">
    <div class="col s12 z-depth-6 card-panel">
        <form class="login-form">
            <div class="row">
                <div class="input-field col s12 center">
                    <img src="{{asset('assets/images/avatar.png')}}" alt="头像" width="30%" class="responsive-img valign profile-image-login">
                    <p style="margin-left: 60px;margin-right: 60px;" class="center login-form-text">输入用户名或者邮箱登录</p>
                </div>
            </div>
            <div class="row margin">
                <div class="input-field col s12">
                    <i class="mdi-social-person-outline prefix"></i>
                    <input id="email" class="validate" name="name" type="text" value="{{\Illuminate\Support\Facades\Cookie::get('username')}}">
                    <label for="email" data-error="wrong" data-success="right" class="center-align">用户名/邮箱</label>
                </div>
            </div>
            <br>
            <div class="row margin">
                <div class="input-field col s12">
                    <i class="mdi-action-lock-outline prefix"></i>
                    <input name="pass" id="password" type="password" value="{{\Illuminate\Support\Facades\Cookie::get('password')}}">
                    <label for="password">密码</label>
                </div>
            </div>
            <div class="row">
                <div class="input-field col s12 m12 l12  login-text">
                    <input type="checkbox" id="remember-me" />
                    <label for="remember-me">记住我</label>
                </div>
            </div>
            <div class="row">
                <div class="input-field col s12">
                    <a onclick="login()" class="btn waves-effect waves-light col s12">登　录</a>
                </div>
            </div>
            <div class="row">
                <div class="input-field col s6 m6 l6">
                    <p class="margin medium-small"><a href="{{url('register')}}">现在注册!</a></p>
                </div>
                <div class="input-field col s6 m6 l6">
                    <p class="margin right-align medium-small"><a href="{{url('forget')}}">忘记密码?</a></p>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    function login(){
        var uname=$("#email").val();
        var pass=$("#password").val();
        var remember=$("#remember-me").is(':checked')?1:0;
        if(uname=='' || pass==''){
            layer.msg('您有未填写项',{icon:5});
            return false;
        }else{
            $.post('{{url('login')}}',{'_token':'{{csrf_token()}}','remember':remember,'username':uname,'password':pass},function(res){
                if(res.status==0){
                    layer.msg(res.msg);
                }else{
                    layer.msg(res.msg);
                    location.href='{{url('index')}}';
                }
            });
        }
    }
</script>
@endsection
